#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <unistd.h>
#include <sys/types.h> 

int main(int argc,char*argv[])
{
	//判断是否是以超级用户的身份运行的程序
	if(getuid() != 0)
	{
		printf("please run as sudo\n");
		exit(0);
	}

	//printf("%d\n",argc);
	if(argc==1)
	{
		printf("输入不能为空！\n");
		exit(0);
	}

	if(!strcmp(argv[1],"--init"))
	{
		printf("Are you sure to change the envirment?[y/n] ");
		char c;
		scanf("%c",&c);
		if (c == 'y')
		{
			system("/usr/share/mydeb/newPreinst");
			system("/usr/share/mydeb/newPostinst");
			printf("success!\n");
		}
		else if(c=='n')
		{
			printf("init cancle\n");
		}
		else
		{
			printf("please check your input!\n");
		}
	}	
	else
	{
		printf("请检查输入！\n");
	}

	return 0;
}
